1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

import { GetServerSideProps } from 'next'
import DefaultErrorPage from 'next/error'
import React from 'react'
import axios from 'axios'

export const getServerSideProps: GetServerSideProps = async (context: any) => {
    const res = await axios.get(`http://127.0.0.1:5000/get/${context.query.id}`)
    if ( !res.data.url ) {
        return {
            props: {}
        }
    }
    return {
        redirect: {
            permanent: false
            ,destination: res.data.url
        }
    }
}

export default function none() {
    return (<DefaultErrorPage statusCode={404} />)
}